import java.util.Comparator;

public class Task implements Comparable<Task> {
    public String name;//任务名称
    public int id; //任务编号
    public int prio; //任务优先级，prio越大优先级越高
    public int needTime;//需要耗时
    public int cpuTime; //已经耗时
    public Task(String name, int needtime) {
        this.name = name;
        this.needTime = needtime;
        prio = 50 - needtime; //短作业优先
        cpuTime = 0;
    }
    public boolean isDone(){
        return cpuTime>=needTime;
    }
    public String ToString(String postfix){
        StringBuilder sb = new StringBuilder();
        sb.append(name);
        sb.append('\t');
        sb.append(prio);
        sb.append('\t');
        sb.append(cpuTime);
        sb.append('\t');
        sb.append(needTime);
        sb.append('\t');
        sb.append(postfix);
        sb.append('\n');
        return sb.toString();
    }

    @Override
    public int compareTo(Task other){
        return this.prio - other.prio;
    }
}